/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpilibj.templates.assets.shooterstates;

import edu.wpi.first.wpilibj.templates.assets.statemachine.State;
import edu.wpi.first.wpilibj.templates.assets.statemachine.StateMachine;
import edu.wpi.first.wpilibj.templates.commands.CommandBase;

/**
 *
 * @author Jarrod Risley
 */
public class ZingStateMachine extends StateMachine {
    
    /*
     * Global Class Variables
     */
    public static State OFF;
    
    public static State MOVE_ONE;
    
    public static State INGEST;
    
    public static State SPIT_OUT;
    
    public static State SHOOT;
    
    public static State CLEAR_SHOOTER;
    
    public static State SPIN_UP_SHOOTER;
    
    // Auton States
    public static State AU_CLEAR;
    public static State AU_SPIN_UP;
    public static State AU_SHOOT;
    
    public static boolean oldSwitchState;
    
    public static boolean switchState;
    
    public static boolean oldSwitchStateLower;
    
    public static boolean switchStateLower;
    
    public static int shooterDiscCount;
    
    // -------------------------------------------------------------------------
    /*
     * This guy needs a special place here. DO NOT MOVE HIM!
     */
    public static ZingStateMachine indexerState = new ZingStateMachine();
    // -------------------------------------------------------------------------
    
    
    // CONSTRUCTOR //
    
    
    private ZingStateMachine() {
        super();
    } // end ZingStateMachine Constructor

    protected void init() {
        
        OFF = OffState.OFF.getChainedInstance(null);
        MOVE_ONE = MoveUpOne.MOVE_UP.getChainedInstance(IngestState.INGEST);
        INGEST = IngestState.INGEST.getChainedInstance(MoveUpOne.MOVE_UP);
        
        SPIT_OUT = RegurgitateState.SPIT_OUT.getChainedInstance(null);
        
        SPIN_UP_SHOOTER = SpinUpShooterState.SPIN_UP.getChainedInstance(SHOOT);
        CLEAR_SHOOTER = ClearShooterState.CLEAR_SHOOTER.getChainedInstance(SPIN_UP_SHOOTER);
        SHOOT = ShootState.SHOOT_STATE.getChainedInstance(null);
        
        AU_SHOOT = AutonShoot.SHOOT_STATE.getChainedInstance(null);
        AU_SPIN_UP = AutonSpinUp.SPIN_UP.getChainedInstance(AU_SHOOT);
        AU_CLEAR = AutonClearState.CLEAR_SHOOTER.getChainedInstance(AU_SPIN_UP);
        
        
        
        
        setFirstState(OFF); // Need this here for now.
        
        switchState = CommandBase.shooter.checkSwitch(1);
        oldSwitchState = switchState;
        
        switchStateLower = CommandBase.shooter.checkSwitch(2);
        oldSwitchStateLower = switchStateLower;
        
    } // end init
    
    /**
     * Sets the old switch state to the value passed in.
     * 
     * @param value The new old state.
     */
    public void setOldSwitchState(boolean value) {
        oldSwitchState = value;
    } // end setOldSwit
    
} // end ZingStateMachine
